<link rel='stylesheet' href='${rc.getContextPath()}/manage/styles/colorPicker/spectrum.css' />
<style>
dl.defectLookup span.error
{
    position:absolute !important;
    left:257px;
}

.sp-dd {
    background: url("${rc.getContextPath()}/manage/styles/dwz/themes/default/images/button/imgX.png");
    background-position: -163px -1px;
    height: 18px;
    width: 16px;
    position: absolute;
    right: 0px;
    top: 0px;
    border: 1px solid #D9DFE5;
}

.sp-replacer {
    padding: 0px;
    border: 0px !important;
    background: #EDF4F5 none repeat scroll 0% 0%;
    width: 146px;
    height: 24px;
    position: relative;
}

.sp-replacer.sp-active {
    border-color: #289BE5;
}

.sp-container, .sp-palette-container {
    border-color: #BDD7E7;
}

.sp-input {
    border: 1px solid #D9DFE5;
}

.sp-preview {
    width: 127px;
    height: 22px;
    border: 1px solid #D9DFE5;
    margin: 0px;
}

</style>
<div class="pageContent">
    <form method="post"
        action="${rc.getContextPath()}/manage/defect/saveDefect"
        class="pageForm required-validate"
        onsubmit="return validateCallback(this,dialogAjaxDone);">
        <div class="pageFormContent" >
            <input type="hidden" name="navTabId" value="${navTabId!''}">
            <input type="hidden" name="id"
                value="<#if (defect.defectText)??>${defect.defectCode!''}</#if>">
            <fieldset>
                <dl>
                    <dt><@label key="defectCode.C,colon">缺陷编号：</@label></dt>
                    <dd>
                        <input name="defectCode" value="<#if (defect.defectCode)??>${defect.defectCode!''}</#if>" 
                              size="22" type="text" maxlength="20" class="required  alphanumeric toUp" warn="<@label key='defectCode.C,alreadyExists'>缺陷编号已存在</@label>"
                              <#if pattern!="add">
                              readonly="readonly"
                              <#else>
                              remote="${rc.getContextPath()}/manage/defect/validateDefectCode"
                             </#if>
                        />
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="defectText.C,colon">缺陷描述：</@label></dt>
                    <dd>
                        <input name="defectText"
                            value="<#if (defect.defectText)??>${defect.defectText!''}</#if>"
                            size="22" type="text" maxlength="60" class="required" 
                          />
                    </dd>
                </dl>
                <dl class="defectLookup">
                    <dt><@label key="defectLevelCode.C,colon">缺陷等级编号：</@label></dt>
                    <dd>
                        <input class="required look" id="defectLevelLookup.defectLevelCode" name="defectLevelCode" value="${defect.defectLevelCode!''}" type="text" postField="defectLevelCode" suggestFields="defectLevelCode,defectLevelText" 
                        suggestUrl="${rc.getContextPath()}/manage/defectLevel/defectLevelDropdown" lookupGroup="defectLevelLookup" 
                            remote="${rc.getContextPath()}/manage/defectLevel/checkDefectLevelCode" warn="<@label key='defectLevelCode.C,doesNotExist.C'>设备类别编号不存在</@label>"/>
                        <a  class="btnLook" href="${rc.getContextPath()}/manage/defectLevel/defectLevelLookup" width="700" height="300" rel="defectLevelLookup_dialog"  lookupGroup="defectLevelLookup" title="<@label key='defectLevelSelect.D'>缺陷等级选择</@label>" ></a>
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="defectLevelText.C,colon">缺陷等级描述：</@label></dt>
                    <dd>
                        <input name="defectLevelText" id="defectLevelLookup.defectLevelText"
                            value="<#if (defect.defectLevelText)??>${defect.defectLevelText!''}</#if>"
                            size="22" type="text" maxlength="60" readonly="readonly"
                          />
                    </dd>
                </dl>
                <dl class="defectLookup">
                    <dt><@label key="responsibilityTypeCode.C,colon">责任类型编号：</@label></dt>
                     <dd>
                        <input class="required look" id="responsibilityTypeLookup.responsibilityTypeCode" name="responsibilityTypeCode" value="${defect.responsibilityTypeCode!''}" type="text" postField="responsibilityTypeCode" suggestFields="responsibilityTypeCode,responsibilityTypeText" 
                        suggestUrl="${rc.getContextPath()}/manage/responsibilityType/responsibilityTypeDropdown" lookupGroup="responsibilityTypeLookup" 
                            remote="${rc.getContextPath()}/manage/responsibilityType/checkResponsibilityTypeCode" warn="<@label key='responsibilityTypeCode.C,doesNotExist.C'>责任类型编号不存在</@label>"/>
                        <a  class="btnLook" href="${rc.getContextPath()}/manage/responsibilityType/responsibilityTypeLookup" width="700" height="300" rel="responsibilityTypeLookup_dialog"  lookupGroup="responsibilityTypeLookup" title="<@label key='responsibilityTypeSelect.D'>责任类型选择</@label>" ></a>
                    </dd> 
                </dl>
                <dl>
                    <dt><@label key="responsibilityTypeText.C,colon">责任类型描述：</@label></dt>
                    <dd>
                        <input name="responsibilityTypeText" id="responsibilityTypeLookup.responsibilityTypeText"
                            value="<#if (defect.responsibilityTypeText)??>${defect.responsibilityTypeText!''}</#if>"
                            size="22" type="text" maxlength="60"  readonly="readonly"
                          />
                    </dd>
                </dl>
                <dl class="defectLookup">
                    <dt><@label key="defectTypeCode.C,colon">缺陷类型编号：</@label></dt>
                    <dd>
                        <input class="required look" id="defectTypeLookup.defectTypeCode" name="defectTypeCode" value="${defect.defectTypeCode!''}" type="text" postField="defectTypeCode" suggestFields="defectTypeCode,defectTypeText" 
                        suggestUrl="${rc.getContextPath()}/manage/defectType/defectTypeDropdown" lookupGroup="defectTypeLookup" 
                            remote="${rc.getContextPath()}/manage/defectType/checkDefectTypeCode" warn="<@label key='defectTypeCode.C,doesNotExist.C'>缺陷类型编号不存在</@label>"/>
                        <a  class="btnLook" href="${rc.getContextPath()}/manage/defectType/defectTypeLookup" width="700" height="300" rel="defectTypeLookup_dialog"  lookupGroup="defectTypeLookup" title="<@label key='defectTypeSelect.D'>缺陷类型选择</@label>" ></a>
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="defectTypeText.C,colon">缺陷类型描述：</@label></dt>
                    <dd>
                        <input name="defectTypeText" id="defectTypeLookup.defectTypeText"
                            value="<#if (defect.defectTypeText)??>${defect.defectTypeText!''}</#if>"
                            size="22" type="text" maxlength="60"  readonly="readonly"
                          />
                    </dd>
                </dl>
                <dl class="defectLookup">
                    <dt><@label key="repairmethodCode.C,colon">返修方法代码：</@label></dt>
                    <dd>
                        <input class="required look" id="repairmethodLookup.repairmethodCode" name="repairmethodCode" value="${defect.repairmethodCode!''}" type="text" postField="repairmethodCode" suggestFields="repairmethodCode,repairmethodText" 
                        suggestUrl="${rc.getContextPath()}/manage/repairmethod/repairmethodDropdown" lookupGroup="repairmethodLookup" 
                            remote="${rc.getContextPath()}/manage/repairmethod/checkRepairmethodCode" warn="<@label key='repairmethodCode.C,doesNotExist.C'>返修方法代码不存在</@label>"/>
                        <a  class="btnLook" href="${rc.getContextPath()}/manage/repairmethod/repairmethodLookup" width="700" height="300" rel="repairmethodLookup_dialog"  lookupGroup="repairmethodLookup" title="<@label key='repairmethodSelect.D'>返修放哪广发选择</@label>" ></a>
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="repairmethodText.C,colon">返修方法描述：</@label></dt>
                    <dd><input id="repairmethodLookup.repairmethodText" value="<#if (defect.repairmethodCode)??>${defect.repairmethodCode!''}</#if>" readonly="readonly" size="22" type="text" maxlength="60" type="text" name="repairmethodText" /></dd>
                </dl>
                
                <dl style="height:40px;">
                    <dt><@label key="backgroundColor.C">背景色：</@label></dt>
                    <dd><input type='text' id="colorPicker" name="backgroundColor" value="${defect.backgroundColor!'#FF0000'}"/></dd>
                </dl>
                
                <dl style="height:40px;">
                    <dd>
                        <label><input type="checkbox" name="pictureFlag" value="1"
                            <#if
                            (defect.pictureFlag)?? && (defect.pictureFlag == 1)>
                            checked="true"</#if>><@label key="pictureFlag.C">图形采集标志</@label></label>
                            
                            <label><input type="checkbox" name="lockFlag" value="1"
                            <#if
                            (defect.lockFlag)?? && (defect.lockFlag == 1)>
                            checked="true"</#if>><@label key="lockFlag.C">锁定标记</@label></label>
                    </dd>
                </dl>
            </fieldset>
            
            <div style="height:130px;width:620px;border:1px solid #d8dfe5;padding:5px 0;overflow-y:auto;">
            <#if defectAttribute??&&(defectAttribute?size>0)>
                <#list defectAttribute as attribute>
                
                         <#if attribute.requiredFlag==1>
                            <#assign required="required">
                         <#else>
                             <#assign required="">
                         </#if>
                        
                         
                    <dl <#if attribute.valueTypeECode=="date">class="defectLookup"</#if>>
                        <dt title="${attribute.attributeText!''}" >
                             <#if ((attribute.attributeText)?length) gt 6 >
                                ${(attribute.attributeText)?substring(0,6)}..
                            <#else>
                                ${(attribute.attributeText)!''}
                            </#if> 
                        <@label key="colon">：</@label></dt>
                        <dd>
                        <input type='hidden' name="defectAttributeValue[${attribute_index}].attributeCode" value="${attribute.attributeCode!''}" />
                        <#if attribute.valueTypeECode=="enum">
                                 
                            <select name="defectAttributeValue[${attribute_index}].attributeValue" 
                                    class="${required!''}">
                                    <#if required!="required">
                                    <option value=""><@label key="selected_first.C">请选择：</@label></option>
                                    </#if>
                                <#list attribute.attributeEnum as attributeEnum>
                                    <option value="${attributeEnum.attributeValue!''}"
                                        <#if attributeEnum.attributeValue==attribute.attributeValue>
                                            selected="selected"
                                        </#if>
                                    >${attributeEnum.attributeValue!''}</option>
                                </#list>
                            </select>
                        <#elseif attribute.valueTypeECode=="date">
                                <input name="defectAttributeValue[${attribute_index}].attributeValue"  type='text' dateFmt="yyyy-MM-dd" 
                                class="${required!''} date" readonly="readonly" value="${attribute.attributeValue!''}" />
                                <a class="inputDateButton" href="javascript:;">选择</a>
                                
                        <#elseif attribute.valueTypeECode=="number">
                                <input name="defectAttributeValue[${attribute_index}].attributeValue"  type='text' maxlength="9"
                                    class="${required!''} number" value="${attribute.attributeValue!''}" placeholder="<@label key="number.M">请输入合法的数字</@label>"/>
                        <#else>
                                 <input name="defectAttributeValue[${attribute_index}].attributeValue"  type='text' maxlength="200"
                                    class="${required!''}"  value="${attribute.attributeValue!''}"/> 
                        </#if>
                        </dd>
                    </dl>
                </#list>
            </#if>            
            </div>
        </div>
        <#if defect??>
            <#assign createInfo=defect>
            <div style="padding: 0px 10px 10px 10px;margin:10px 0;" >
                <div class="createInfo" style="width:600px;">
                    <p>
                        <label class="user"><@label key="createUser.C,colon">创建人：</@label><#if (createInfo.createUser)??>${createInfo.createUser}</#if></label> <label class="time"><@label key="createDateTime.C,colon">创建时间：</@label><#if (createInfo.createDateTime)??>${createInfo.createDateTime?string("yyyy-MM-dd HH:mm:ss")}</#if></label>
                    </p>
                    <p>
                        <label class="user"><@label key="modifyUser.C,colon">修改人：</@label><#if (createInfo.modifyUser)??>${createInfo.modifyUser}</#if></label> <label class="time"><@label key="modifyDateTime.C,colon">修改时间</@label><#if (createInfo.modifyDateTime)??>${createInfo.modifyDateTime?string("yyyy-MM-dd HH:mm:ss")}</#if></label>
                    </p>
                </div>
            </div>
        </#if>
        <div class="formBar">
            <ul>
                    <li>
                        <div class="buttonActive">
                            <div class="buttonContent">
                                <button type="submit"><@label key="save.B">保存</@label></button>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="buttonActiveGrey">
                            <div class="buttonContent">
                                    <button type="button" class="close" ><@label key="cancel.B">取消</@label></button>
                            </div>
                        </div>
                    </li>
            </ul>
        </div>
    </form>
</div>
<script>
$(function(){
    var dialog= $.pdialog.getCurrent();
    var colorPicker=$("#colorPicker", dialog);
    var colorVal=colorPicker.val();
    var colorOption={
            color: colorVal,
            chooseText: "<@label key='select.C'>选择</@label>",
            cancelText: "<@label key='cancel.B'>取消</@label>",
            showInput: true,
            preferredFormat: "hex",
            showInput: true,
            showPalette: true,
            palette: [
                ["#000","#444","#666","#999","#ccc","#eee","#f3f3f3","#fff"],
                ["#f00","#f90","#ff0","#0f0","#0ff","#00f","#90f","#f0f"],
                ["#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#cfe2f3","#d9d2e9","#ead1dc"],
                ["#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#9fc5e8","#b4a7d6","#d5a6bd"],
                ["#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6fa8dc","#8e7cc3","#c27ba0"],
                ["#c00","#e69138","#f1c232","#6aa84f","#45818e","#3d85c6","#674ea7","#a64d79"],
                ["#900","#b45f06","#bf9000","#38761d","#134f5c","#0b5394","#351c75","#741b47"],
                ["#600","#783f04","#7f6000","#274e13","#0c343d","#073763","#20124d","#4c1130"]
            ]
        };

    colorPicker.spectrum(colorOption);
    $('.sp-dd', dialog).empty();
});


</script>
